<?php $products = isset($products) ? $products :array();?>
<div class='container-fluid'>
<?php echo View::make('share.backend_nav')->with('nav', Config::get('app.nav.product.sub'));?>
<div class='board'>

<div style='height:120px;min-height:120px;border:3px solid #ddd;'>
<div class='header'>
    <p>筛选条件</p>
</div>
  <form style='margin-left:10px;margin-top:10px;' method='get'>
    <div class="control-group">
    <label for='category_id'>商品类型</label>
    <select name='category_id' class='span2'>
      <option value=0>请选择</option>
      <?php $cates = Category::all();?>
      <?php $category_id = Input::get('category_id', false)?>
      <?php foreach ($cates as $c):?>
      <option value='<?php echo $c->id;?>' <?php if ($c->id == $category_id) echo 'selected="selected"'?>><?php echo $c->cname;?></option>
      <?php endforeach;?>
    </select>
    </div>

    <div class="control-group">
      <label for='tag'>Tag</label>
      <?php $tag = strval(Input::get('tag', ''));?>
      <input type='text' name='tag' class='input' value='<?php echo $tag?>' autocomplete='off'/>
    </div>
<!--
    <div class="control-group">
      <label for='sort'>排序</label>
      <?php 
        $sort = Input::get('sort', 'default');
        $sort_array = array(
          'default' => '默认排序',
          'price_desc' => '折扣价格从高到低',
          'price_asc'  => '折扣价格从低到高',
          'commissionRate_desc' => '佣金比率从高到低',
          'commissionRate_asc'  => '佣金比率从低到高',
          'volume_desc' => '成交量从高到低',
          'volume_asc' => '成交量从低到高'
        );
      ?>
      <select name='sort' class='span2'>
      <?php foreach ($sort_array as $k => $v):?>
        <option <?php if($sort == $k) echo 'selected="selected"'?>value='<?php echo $k;?>'><?php echo $v;?></option>
      <?php endforeach;?>
      </select>
    </div>
-->

    <div class="control-group">
      <button type='submit' class='btn btn-success' style='margin-top:25px;' id='set_auto' >查找</button>
    </div>
    <div style='clear:both;'></div>
  </form>
</div>
<div style='height:10px;'></div>

<span class='label label-info'>商品列表</span>
<a href='/product/add/' target='_blank' class='label label-success  pull-right' >手动添加商品</a>
<table class='table table-bordered'>
  <thead>
    <tr>
      <th class='img' style='width:100px;'>#IMG</th>
      <th class='title'>#名称</th>
      <th class='price'>#价格</th>
      <th class='coupon_price'>#折扣价</th>
      <th class='coupon_rate'>#折扣率</th>
      <th class='tags'>#Tags</th>
      <th class='coupon_start_time'>#开始时间</th>
      <th class='coupon_end_time'>#结束时间</th>
      <th class='op' style='width:40px;'>#OP</th>
      <th class='op' style='width:40px;'>#OP</th>
    </tr>
  </thead>
  <tbody>
  <?php foreach ($products as $m):?>
    <tr>
      <td><img src='<?php echo $m->pic_url . '_120x120.jpg';?>' style='height:90px;width:90px;'/></td>
      <td><a href='<?php echo $m->url?>' target='_blank'><?php echo $m->title;?></a></td>
      <td><?php echo $m->price;?></td>
      <td><?php echo $m->coupon_price;?></td>
      <td><?php echo $m->coupon_rate / 100 . '%';?></td>
      <td>
      <?php foreach ($m->tags as $t):?>
         <span class='label'><?php echo $t->name;?></span>
      <?php endforeach;?>
      </td>
      <td><?php echo $m->coupon_start_time;?></td>
      <td><?php echo $m->coupon_end_time;?></td>
      <td><a href='javascript:void(0)' class='btn btn-mini btn-primary edit' data-product-id='<?php echo $m->id;?>' >编辑</a></td>
      <td><a href='javascript:void(0)' class='btn btn-mini btn-danger delete' data-product-id='<?php echo $m->id;?>' >删除</a></td>
    </tr>
  <?php endforeach;?>
  </tbody>
</table>
    <div class="pagination pull-right">
      <ul><?php echo $page;?></ul>
    </div>
</div>
</div>
